from datetime import datetime
import boto3
import json

client = boto3.client('events')


def trigger_initiator():
    detail = {"state": "STARTED",
              "metadata": {
                  "SpiderName": "SelectiveSpider",
                  "InitiatorName": "CoreProducts"
              },
              "payload": {
                  "batchId": "2021-07-02",
                  "athena_sql": 'SELECT "rawNodeId", "rank", "LowestPrice" FROM "coreproducts"."manual_testingttt_2021_07_01" where rawnodeid=\'12897221\'',
                  "s3_path": "s3://pt-data-dev/staging/best-sellers/flatten_2021-07-02-manual/",
              }
              }
    putEventsResp = client.put_events(
        Entries=[
            {
                # 'Time': datetime(2015, 1, 1),
                "Source": "pt.spider",
                # 'Resources': [
                #     'string',
                # ],
                "DetailType": "Spider State-change Notification",
                "Detail": json.dumps(detail),
                # 'EventBusName': 'string',
                # 'TraceHeader': 'string'
            },
        ]
    )
    print(putEventsResp)
    print("done")


if __name__ == "__main__":
    trigger_initiator()
